module MC.View {
	export module pic {

		export function load() {
			let bFileDivList = $('.bFileDiv');
			for (let i = 0; i < bFileDivList.length; i++) {
				let obj = $(bFileDivList[i]);
				let pcid = obj.attr('id');
				if(obj.attr('TXupfileDiv')=='true'){
                    continue;
				}
				let bixu = ``;
				if (obj.attr('bixu') == 'true') {
					bixu = `<span class="red">*</span>`;
				}
				let title = obj.attr('title');///<input type="hidden" id="sfzzm" value="" class="sfzFileVal">
				let html = `
				<div class="pic">
						
						<img class="img" />
					</div>
            <p class="spantitle">`+ bixu + `` + title + `</p>
		`;
				obj.html(html);
			}

			$('body').on('click', '.bFileDiv .pic', function () {
				let obj = $(this);
				let pcid = obj.parent().attr('id');
				if(obj.parent().attr('TXupfileDiv')=='true'){
					return;
				}
				MC.API.UpPic((url: string) => {
					///console.log(pcid,url);	
					obj.find('.img').attr('src', url);
					$('[id=' + pcid + ']').val(url);
				});
			});
		}

		/** 给图片赋值 */
		export function loadData() {
			let bFileDivList = $('.bFileDiv');
			for (let i = 0; i < bFileDivList.length; i++) {
				let obj = $(bFileDivList[i]);
				let val = obj.val();
				obj.find('.img').attr('src', val); 
			}
		}




	}
}